package com.ms.game.billing;

import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

import com.xpec.c4.db.model.basic.BasicGameModel;


/**
 * 遊戲儲值申請&歷程記錄
 * @author TW15012
 */

@Entity
@org.hibernate.annotations.Entity(dynamicInsert=true,dynamicUpdate=true)
@Table(name = "game_billing",uniqueConstraints = {
		@UniqueConstraint(columnNames = { "orderID" })
		})

@org.hibernate.annotations.Table(
		appliesTo = "game_billing", indexes = {
				@org.hibernate.annotations.Index(name = "IDX_ACCOUNT_ID", columnNames = { "playerID" , "orderID"})
		})
public class GameBillingModel extends BasicGameModel {

	/**
	 * 訂單創立
	 */
	public static final String STAT_CREATE = "CREATE";
	
	/**
	 * 進入驗證
	 */
	public static final String STAT_START_VERIFY = "START_VERIFY";	
	
	/**
	 * 進入驗證
	 */
	public static final String STAT_END_VERIFY = "END_VERIFY";
	
	/**
	 * 第二步過期
	 */
	public static final String STAT_SECOND_EXPIRED = "SECOND_EXPIRED";

	/**
	 * 第二步驗證失敗
	 */
	public static final String STAT_SECOND_VERIFY_FAILED = "SECOND_VERIFY_FAILED";
	
	/**
	 * 驗證超時
	 */
	public static final String STAT_SECOND_VERIFY_TIMEOUT = "SECOND_VERIFY_TIMEOUT";
	
	/**
	 * 第三步過期
	 */
	public static final String STAT_THIRD_EXPIRED = "THIRD_EXPIRED";

	/**
	 * 第三步驗證失敗
	 */
	public static final String STAT_THIRD_VERIFY_FAILED = "THIRD_VERIFY_FAILED";

	/**
	 * 整筆訂單完成
	 */
	public static final String STAT_COMPLETE = "COMPLETE";
	
	
	/**
	 * 累加儲值限制失敗
	 */
	public static final String STAT_ADD_LIMIT_FAILED = "ADD_STORE_LIMIT_FAILED";
	
	/**
	 * 補點完成
	 */
	public static final String STAT_RESUPPLY_COMPLETE = "RESUPPLY_COMPLETE";
	
	
	/**
	 * 被後台取消補點資格
	 */
	public static final String STAT_USER_CANCEL = "USER_CANCEL";
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3943606250118675636L;
	
	private Date eventTime;
	
	private long modify_time;
	
	private long create_time;
	
	private String accountID;
	
	private String playerID;
	
	private String orderID;
	
	/**
	 * google/apple 傳來的orderId
	 */
	private String iapOrderId;
	
	private long expiretime;
	
	private String pid;
	
	private String verify_stat;
	
	/**
	 * app store or google play的 psl
	 */
	private String productId;
	
	/**
	 * 帶給官網平台的參數
	 */
	private String params;

	/**
	 * 平台的回傳
	 */
	private String platformresult;
	
	/**
	 * google 驗證用
	 */
	private String signature;
	
	/**
	 * 儲值資訊
	 */
	private String purchaseInfo;
	
	
	/**
	 * 蘋果收據(驗證用)
	 */
	private String receipt;
	
	/**
	 * 玩家的ip
	 **/
	private String playerIp;
	
	/**
	 * 訂單備註 目前用於 USER_CANCEL 填寫原因
	 */
	private String notes;
	
	/**
	 * 儲值金額
	 */
	private BigDecimal iapValue;

	@Column(columnDefinition="VARCHAR(500) default ''")
	public String getPlatformresult() {
		return platformresult;
	}

	public void setPlatformresult(String platformresult) {
		this.platformresult = platformresult;
	}
	
	@Column(columnDefinition = "TEXT")
	public String getParams() {
		return params;
	}
	
	public void setParams(String params) {
		this.params = params;
	}

	@Temporal(TemporalType.TIMESTAMP)
	public Date getEventTime() {
		return eventTime;
	}

	public void setEventTime(Date eventTime) {
		this.eventTime = eventTime;
	}

	@Column(columnDefinition="VARCHAR(55) default ''")
	public String getAccountID() {
		return accountID;
	}

	public void setAccountID(String accountID) {
		this.accountID = accountID;
	}

	@Column(columnDefinition="VARCHAR(55) default ''")
	public String getPlayerID() {
		return playerID;
	}

	public void setPlayerID(String playerID) {
		this.playerID = playerID;
	}

	@Column(columnDefinition="VARCHAR(55) default ''")
	public String getOrderID() {
		return orderID;
	}

	public void setOrderID(String orderID) {
		this.orderID = orderID;
	}
	
	public String getIapOrderId() {
		return iapOrderId;
	}

	public void setIapOrderId(String iapOrderId) {
		this.iapOrderId = iapOrderId;
	}

	public long getExpiretime() {
		return expiretime;
	}

	public void setExpiretime(long expiretime) {
		this.expiretime = expiretime;
	}

	@Column(columnDefinition="VARCHAR(30) default ''")
	public String getVerify_stat() {
		return verify_stat;
	}

	public void setVerify_stat(String verify_stat) {
		this.verify_stat = verify_stat;
	}

	public long getModify_time() {
		return modify_time;
	}

	public void setModify_time(long modify_time) {
		this.modify_time = modify_time;
	}

	public long getCreate_time() {
		return create_time;
	}

	public void setCreate_time(long create_time) {
		this.create_time = create_time;
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}
	
	@Column(columnDefinition = "TEXT")
	public String getSignature() {
		return signature;
	}

	public void setSignature(String signature) {
		this.signature = signature;
	}

	@Column(columnDefinition = "TEXT")
	public String getPurchaseInfo() {
		return purchaseInfo;
	}

	public void setPurchaseInfo(String purchaseInfo) {
		this.purchaseInfo = purchaseInfo;
	}

	public String getPlayerIp() {
		return playerIp;
	}

	public void setPlayerIp(String playerIp) {
		this.playerIp = playerIp;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		this.notes = notes;
	}

	@Column(columnDefinition = "TEXT")
	public String getReceipt() {
		return receipt;
	}

	public void setReceipt(String receipt) {
		this.receipt = receipt;
	}

	@Column(precision = 19, scale = 2, columnDefinition = "DECIMAL(19,2) default 0.0")
	public BigDecimal getIapValue() {
		return iapValue;
	}

	public void setIapValue(BigDecimal iapValue) {
		this.iapValue = iapValue;
	}

	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}
}
